package com.mt.api.modules.manager.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mt.api.modules.domain.AppBoss;
import com.mt.api.modules.domain.bo.AppBossListBo;
import com.mt.api.modules.manager.IBossManager;
import com.mt.api.modules.mapper.AppBossMapper;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author: plover
 * @Date: 2022-01-02
 * @Description:
 */
@Component
public class BossManagerImpl extends ServiceImpl<AppBossMapper, AppBoss> implements IBossManager {

    @Override
    public List<AppBoss> getBossList(AppBossListBo bo) {
        LambdaQueryWrapper<AppBoss> wrapper = Wrappers.lambdaQuery();
        return baseMapper.selectList(wrapper);
    }

    @Override
    public AppBoss getBossByPhone(String phone) {
        LambdaQueryWrapper<AppBoss> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(AppBoss::getPhone, phone)
                .last("limit 1");
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public AppBoss getBossByOpenId(String openId) {
        LambdaQueryWrapper<AppBoss> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(AppBoss::getOpenId, openId)
                .last("limit 1");
        return baseMapper.selectOne(wrapper);
    }

}
